package www.shuang.common.interceptor;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import www.shuang.users.pojo.AAdmins;
import www.shuang.users.service.IAAdminsService;

@Component("adminsInterceptor")
public class AdminsInterceptor extends HandlerInterceptorAdapter
{
	@Resource
	private IAAdminsService adminsService;
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
	{
		
		//从session中获取
		HttpSession session=request.getSession();
		AAdmins admins=(AAdmins) session.getAttribute("admins");
		if(admins != null){
			return true;
		}
		String info="请先登陆";
		session.setAttribute("info", info);
		response.sendRedirect(request.getContextPath()+"/adminsLogin.htm");
		return false;
		
	}
		
}
